package org.Demo2;

import java.io.Console;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Properties;

public class Create {
    public static void main(String[] args) throws IOException, ClassNotFoundException, NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException {
        Properties properties =new Properties();
        FileInputStream fis=new FileInputStream("C:\\Users\\夏明毅\\Desktop\\java课程代码\\MyReflect\\prop.properties");
        properties.load(fis);
        fis.close();
        String className = (String) properties.get("className");
        String methodName= (String) properties.get("methodName");
        Class aClass = Class.forName(className);
        Constructor con = aClass.getConstructor(String.class,int.class);
        Object xia = con.newInstance("xia", 21);
        Method declaredMethod = aClass.getDeclaredMethod(methodName);
        System.out.println(declaredMethod.invoke(xia));
        
    }
}
